﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DA
{
    public class ChucVu_DA
    {
        QLKhachSanDataContext ql;
        public List<ChucVu> LayDSCV()
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.ChucVus.ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ql.Dispose();
            }
        }
        public string LayTenCVTheoMaCV(string macv)
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.ChucVus.Where(p => p.MaCV == macv).Select(p => p.TenCV).FirstOrDefault();
            }
            catch
            {
                return null;
            }
            finally
            {
                ql.Dispose();
            }
        }
        public bool suacv(ChucVu c)
        {
            try
            {
                ql = new QLKhachSanDataContext();
                ChucVu cv= ql.ChucVus.Where(p => p.MaCV ==c.MaCV).FirstOrDefault();
                cv.Luong = c.Luong;
                ql.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                ql.Dispose();
            }
        }
    }
}
